<template>
  <div class="login_page">

    <div class="login">
        <div class="top"> <router-link tag="div" to="/bookshop" class="iconfont icon-zuojiantou" ></router-link > 登录</div>
      <div class="iconfont icon-wangyiyunyuedu"></div>
      <div class="form">
        <div class="item">
          <span class="iconfont icon-search"></span>
          <input type="text" placeholder="手机号码" v-model="phone" />
        </div>
        <div class="item">
          <span class="iconfont icon-search"></span>
          <input type="password" placeholder="密码" v-model="password" />
        </div>

        <div class="item">
          <div class="submit" @click="submit">提交</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      phone: "",
      password: "",
    };
  },
  methods: {
    submit() {
      // 1.验证手机号码
      let reg = /^(?:(?:\+|00)86)?1[3-9]\d{9}$/;
      if (!reg.test(this.phone)) {
        this.$toast("手机错误");
        return;
      }
      // 密码验证
      let regPassword = /^[a-zA-Z]\w{5,17}$/;
      if (!regPassword.test(this.password) || this.password=="") {
        this.$toast("请输入正确密码");
        return
      }

        window.localStorage.setItem("token", "登录了");
        this.$router.push({name:"my"});
        
      
    },
  },
};
</script>

<style lang="less">
.login_page {
  z-index: 999;
  height: 100vh;
}
.login {
  background-color: #dfdfdf;
  width: 100%;
  height: 100%;
  color: #fff;

  .top{
    height: 40px;
    text-align: center;
    background-color: #eee;
    font-size: 18px;
    line-height: 40px;
    color: black;
    position: relative;
    .icon-zuojiantou{
        width: 30px;
        position: absolute;
        top: 0;
        left: 0;
    }
  }
}
.icon-wangyiyunyuedu {
  font-size: 60px;
  text-align: center;
  height: 48px;
  padding: 150px 0 40px 0;
  color: #C40813;
}
.form {
  .item {
    width: 76%;
    height: 30px;
    line-height: 30px;
    margin: 0 auto;
    background-color: #eee;
    border-radius: 30px;
    margin-bottom: 12px;
    input {
      background-color: transparent;
      border: 0px;
      outline: none;
      text-indent: 0.5em;
      font-size: 14px;
      color: #000;
    }
    span {
      font-size: 20px;
      margin-left: 10px;
      display: inline-block;
      vertical-align: middle;
    }
    .getCode {
      border: 1px solid #eee;
      height: 20px;
      line-height: 20px;
      width: 50px;
      border-radius: 20px;
      font-size: 12px;
      color: #808080;
      float: right;
      margin: 5px;
    }
    .submit {
      font-size: 15px;
      background-color: #eee;
      text-align: center;
      color: #d4473c;
      border-radius: 15px;
    }
  }
}
</style>